#ifndef __PACKET_QUEUE_H__
#define __PACKET_QUEUE_H__

#include "SDL.h"
#if defined(__cplusplus)
extern "C" {
#endif
#define __STDC_CONSTANT_MACROS
#include "libavcodec/avcodec.h"
#if defined(__cplusplus)
}
#endif


typedef struct QueueElem {
    AVPacket pkt;
    struct QueueElem *prev;
    struct QueueElem *next;
} QUEUE_ELEMENT;

class PacketQueue {
  public:
    PacketQueue();
    ~PacketQueue();

    bool Push(AVPacket *pPkt);
    bool Pop(AVPacket *pPkt, bool block);
    unsigned int Clear();
    unsigned int GetElementCount();
    unsigned int GetTotalDataSize();

  private:
    QUEUE_ELEMENT *pFirstElement_;
    QUEUE_ELEMENT *pLastElement_;
    unsigned int elementNum_;
    unsigned int totalDataSize_;
    SDL_mutex *pMutex_;
	SDL_cond *pCond_;
};

#endif